home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-19 | 25.6 KB | 814 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWSemInt.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWSEMINT_H
- #include "FWSemInt.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWACQSCR_H
- #include "FWAcqScr.h"
- #endif
-
- #ifndef FWEXTMGR_H
- #include "FWExtMgr.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef PRSIGLUE_H
- #include "PRSIGlue.h"
- #endif
-
- #ifndef FWAPLEVT_H
- #include "FWAplEvt.h"
- #endif
-
- #ifndef FWDSCOPR_H
- #include "FWDscOpr.h"
- #endif
-
- #ifndef FWSCPCAL_H
- #include "FWScpCal.h"
- #endif
-
- #ifndef FWSCPCOL_H
- #include "FWScpCol.h"
- #endif
-
- #ifndef FWSCPTBL_H
- #include "FWScptbl.h"
- #endif
-
- #ifndef FWPRTSCP_H
- #include "FWPrtScp.h"
- #endif
-
- #ifndef FWSCPPRP_H
- #include "FWScpPrp.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- #ifndef FWEVENTU_H
- #include "FWEventU.h"
- #endif
-
- #ifndef FWINK_H
- #include "FWInk.h"
- #endif
-
- #ifndef FWOVLSHP_H
- #include "FWOvlShp.h"
- #endif
-
- #ifndef SOM_FW_OSemanticInterface_xh
- #include "SLSemInt.xh"
- #endif
-
- #ifndef FWSOMENV_H
- #include "FWSOMEnv.h"
- #endif
-
- #ifndef FWSESION_H
- #include "FWSesion.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_StandardExtensions_defined
- #include <StdExts.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_ODRegistry_defined
- #include <ODRgstry.xh>
- #endif
-
- #ifndef SOM_ODNameResolver_xh
- #include <NamRslvr.xh>
- #endif
-
- #ifndef SOM_ODObjectSpec_xh
- #include <ODObjSpc.xh>
- #endif
-
- #ifndef SOM_ODOSLToken_xh
- #include <ODOSLTkn.xh>
- #endif
-
- // ----- Macintosh Includes -----
-
- #ifndef __ASREGISTRY__
- #include <ASRegistry.h>
- #endif
-
- //========================================================================================
- // Runtime Information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwsemevt
- #endif
-
- FW_DEFINE_AUTO(FW_CSemanticInterface)
-
- //========================================================================================
- // class FW_CSemanticInterface
- //========================================================================================
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::FW_CSemanticInterface
- //---------------------------------------------------------------------------------------
-
- FW_CSemanticInterface::FW_CSemanticInterface(Environment* ev, FW_CPart* part) :
- fDefaultContainer(FW_DYNAMIC_CAST(FW_MPartScriptable, part)),
- fPart(part),
- fOSLFlags(kAEIDoMinimum),
- fUsingPredispatchProc(FALSE)
- {
- FW_UNUSED(ev);
-
- FW_END_CONSTRUCTOR
-
- // OpenDoc releases 1.0 - 1.04 (possibly later) have a bug that prevents marking
- // from working correctly. The bug causes OpenDoc to look at the OSL flags of
- // the part's containing part when determining whether or not a part marks. This
- // means that if a part says it does marking, OpenDoc will treat it as if it does
- // not, but will treat all parts contained by that part as if they do.
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::~FW_CSemanticInterface
- //---------------------------------------------------------------------------------------
-
- FW_CSemanticInterface::~FW_CSemanticInterface()
- {
- FW_START_DESTRUCTOR
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CreateSOMInterface
- //---------------------------------------------------------------------------------------
-
- FW_OSemanticInterface* FW_CSemanticInterface::CreateSOMInterface(Environment *ev,
- FW_CPart *part,
- const char *name,
- void* refCon)
- {
- FW_UNUSED(name);
- FW_UNUSED(refCon);
- FW_OSemanticInterface* semInt = new FW_OSemanticInterface;
- semInt->InitODFSemanticInterface(ev, part->GetODPart(ev), FW_CSession::GetODSession(ev), this, FW_PrivGetSemanticInterfaceGlue());
-
- semInt->SetOSLSupportFlags(ev, fOSLFlags);
- semInt->UsingPredispatchProc(ev, fUsingPredispatchProc);
-
- return semInt;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::AcquireSOMInterface
- //---------------------------------------------------------------------------------------
-
- FW_OSemanticInterface* FW_CSemanticInterface::AcquireSOMInterface(Environment* ev)
- {
- return (FW_OSemanticInterface*)fPart->GetExtensionManager(ev)->AcquireExtension(ev, kODExtSemanticInterface, FW_kDontCreateExtension);
- }
-
- //========================================================================================
- // Begin Callbacks
- //========================================================================================
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CallEventHandler
- //---------------------------------------------------------------------------------------
-
- void FW_CSemanticInterface::CallEventHandler(Environment* ev,
- FW_CAppleEvent& event,
- FW_CAppleEvent& reply)
- {
- // FW_DebugIdentifyPart(ev, fPart->GetLastActiveFrame(ev), FW_kRGBBlack);
-
- FW_CAcquiredScriptable targetObject = AcquireTargetObject(ev, event);
-
- AEKeyword eventClass = event.GetEventClass();
- AEKeyword eventID = event.GetEventID();
-
- // FW_DebugIdentifyPart(ev, fPart->GetLastActiveFrame(ev), FW_kRGBGreen);
-
- targetObject->HandleSemanticEvent(ev, fPart, eventClass, eventID, event, reply);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CallCoercionHandler
- //---------------------------------------------------------------------------------------
-
- void FW_CSemanticInterface::CallCoercionHandler(Environment* ev,
- const FW_CDesc& theDesc,
- ODDescType toType,
- FW_CDesc& theResult)
- {
- FW_UNUSED(ev);
- FW_Handled handled = FW_CDescCoercionCallbacks::InvokeHandler(theDesc, toType, theResult);
- if (handled == FW_kNotHandled)
- FW_Failure(errAECoercionFail);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CallPredispatchProc
- //---------------------------------------------------------------------------------------
-
- void FW_CSemanticInterface::CallPredispatchProc(Environment* ev,
- FW_CAppleEvent& event,
- FW_CAppleEvent& reply)
- {
- FW_UNUSED(ev);
- FW_UNUSED(event);
- FW_UNUSED(reply);
- FW_Failure(errAEEventNotHandled);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CallObjectAccessor
- //---------------------------------------------------------------------------------------
-
- void FW_CSemanticInterface::CallObjectAccessor(Environment* ev,
- ODDescType desiredClass,
- ODOSLToken* container,
- ODDescType containerClass,
- ODDescType form,
- FW_CDesc& selectionData,
- ODOSLToken* value)
- {
- // FW_DebugIdentifyPart(ev, fPart->GetLastActiveFrame(ev), FW_kRGBBlue);
-
- FW_CDesc containedObjectToken(GetDescFromToken(ev, value));
- FW_CDesc containerToken(GetDescFromToken(ev, container));
- FW_CAcquiredScriptable acquiredObject;
-
- // OpenDoc 1.0 doesn't handle OSLSupportFlags correctly.
- // Instead of respecting our request for object marking,
- // we get a container token here that is a list built
- // by the OD OSL. For now, we'll simulate marking by
- // building generating a collection of marked objects ourselves.
-
- if (containerToken.IsList() && desiredClass == cProperty)
- {
- ODDescType whichProperty;
-
- selectionData >> whichProperty;
- acquiredObject = CreateCollectionFromList(ev, fPart, containerToken, whichProperty);
- }
- else
- {
- if (containerClass == cPart)
- {
- FW_MPartScriptable* part = GetDefaultContainer();
- acquiredObject = part->AcquireObjectContainedInPart(ev, desiredClass, form, selectionData);
- }
- else
- {
- FW_MScriptable* containerObject;
-
- if (containerToken.IsNullDescriptor())
- containerObject = GetDefaultContainer();
- else
- containerObject = ::FW_ExtractScriptableFromDesc(containerToken);
-
- acquiredObject = containerObject->AcquireContainedObject(ev, fPart, desiredClass, form, selectionData);
- }
-
- }
-
- if (acquiredObject != NULL)
- ::FW_InsertScriptableIntoDesc(acquiredObject, containedObjectToken);
- else
- FW_Failure(errAEEventNotHandled);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CallCompareProc
- //---------------------------------------------------------------------------------------
-
- void FW_CSemanticInterface::CallCompareProc(Environment* ev,
- ODDescType oper,
- ODOSLToken* obj1,
- ODOSLToken* obj2,
- ODBoolean* result)
- {
- FW_CDesc desc1(GetDescFromToken(ev, obj1));
- FW_CDesc desc2(GetDescFromToken(ev, obj2));
-
- if (desc1.DescriptorType() == FW_kSemanticObjectTokenType)
- {
- FW_MScriptable* semanticObject = ::FW_ExtractScriptableFromDesc(desc1);
- *result = semanticObject->CompareScriptableObjects(ev, fPart, oper, desc2);
- }
- else
- FW_Failure(errAEEventNotHandled);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CallCountProc
- //---------------------------------------------------------------------------------------
- void FW_CSemanticInterface::CallCountProc(Environment* ev,
- ODDescType desiredClass,
- ODDescType containerClass,
- ODOSLToken* container,
- ODSLong* result)
- {
- FW_CDesc containerToken(GetDescFromToken(ev, container));
-
- long elementCount = 0;
-
- if (containerClass == cPart)
- {
- elementCount = GetDefaultContainer()->CountElementsInPart(ev, desiredClass);
- }
- else
- {
- FW_MScriptable* containerObject = NULL;
-
- if (containerToken.IsNullDescriptor())
- containerObject = GetDefaultContainer();
- else
- containerObject = ::FW_ExtractScriptableFromDesc(containerToken);
-
- elementCount = containerObject->CountElements(ev, fPart, desiredClass);
- }
-
- *result = elementCount;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CallDisposeTokenProc
- //---------------------------------------------------------------------------------------
- void FW_CSemanticInterface::CallDisposeTokenProc(Environment* ev, ODOSLToken* unneededToken)
- {
- FW_CDesc token(GetDescFromToken(ev, unneededToken));
-
- if (token.DescriptorType() == FW_kSemanticObjectTokenType)
- {
- FW_MScriptable* scriptableObject = ::FW_ExtractScriptableFromDesc(token);
- scriptableObject->ReleaseScriptable();
- token.Clear();
- }
- else
- FW_Failure(errAEEventNotHandled);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CallGetErrDescProc
- //---------------------------------------------------------------------------------------
- void FW_CSemanticInterface::CallGetErrDescProc(Environment* ev, ODDesc** errDesc)
- {
- FW_UNUSED(ev);
- FW_UNUSED(errDesc);
- FW_Failure(errAEEventNotHandled);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CallGetMarkTokenProc
- //---------------------------------------------------------------------------------------
- void FW_CSemanticInterface::CallGetMarkTokenProc(Environment* ev,
- ODOSLToken* dContainerToken,
- ODDescType containerClass,
- ODOSLToken* result)
- {
- FW_UNUSED(dContainerToken);
- FW_UNUSED(containerClass);
-
- // FW_DebugIdentifyPart(ev, fPart->GetLastActiveFrame(ev), FW_kRGBBlue);
-
- FW_CDesc collectionToken(GetDescFromToken(ev, result));
-
- FW_CAcquiredScriptable collection = FW_NEW(FW_CScriptableCollection, ());
- ::FW_InsertScriptableIntoDesc(collection, collectionToken);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CallMarkProc
- //---------------------------------------------------------------------------------------
- void FW_CSemanticInterface::CallMarkProc(Environment* ev,
- ODOSLToken* objectToMarkToken,
- ODOSLToken* markingListToken,
- ODSLong index)
- {
- FW_UNUSED(index);
-
- // FW_DebugIdentifyPart(ev, fPart->GetLastActiveFrame(ev), FW_kRGBRed);
-
- FW_CDesc objectToMarkDesc(GetDescFromToken(ev, objectToMarkToken));
- FW_CDesc markingListDesc(GetDescFromToken(ev, markingListToken));
-
- FW_MScriptable* objectToMark = ::FW_ExtractScriptableFromDesc(objectToMarkDesc);
- FW_CScriptableCollection* collection =
- FW_DYNAMIC_CAST(FW_CScriptableCollection, ::FW_ExtractScriptableFromDesc(markingListDesc));
-
- collection->Add(objectToMark);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CallAdjustMarksProc
- //---------------------------------------------------------------------------------------
- void FW_CSemanticInterface::CallAdjustMarksProc(Environment* ev,
- ODSLong newStart,
- ODSLong newStop,
- ODOSLToken* markToken)
- {
- // FW_DebugIdentifyPart(ev, fPart->GetLastActiveFrame(ev), FW_kRGBGreen);
-
- FW_CDesc markingListDesc(GetDescFromToken(ev, markToken));
- FW_CScriptableCollection* collection =
- FW_DYNAMIC_CAST(FW_CScriptableCollection, ::FW_ExtractScriptableFromDesc(markingListDesc));
-
- collection->AdjustMarks(ev, newStart, newStop);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::GetOSLSupportFlags
- //---------------------------------------------------------------------------------------
-
- ODSShort FW_CSemanticInterface::GetOSLSupportFlags(Environment* ev)
- {
- FW_UNUSED(ev);
- return fOSLFlags;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::SetOSLSupportFlags
- //---------------------------------------------------------------------------------------
-
- void FW_CSemanticInterface::SetOSLSupportFlags(Environment* ev, ODSShort flags)
- {
- fOSLFlags = flags;
-
- FW_OSemanticInterface* semInt = AcquireSOMInterface(ev);
- if (semInt)
- {
- semInt->SetOSLSupportFlags(ev, flags);
- semInt->Release(ev);
- }
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::UsingPredispatchProc
- //---------------------------------------------------------------------------------------
-
- void FW_CSemanticInterface::UsingPredispatchProc(Environment* ev, ODBoolean usingNotUsing)
- {
- fUsingPredispatchProc = usingNotUsing;
-
- ODSemanticInterface* semInt = AcquireSOMInterface(ev);
- if (semInt)
- {
- semInt->UsingPredispatchProc(ev, usingNotUsing);
- semInt->Release(ev);
- }
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::CreateCollectionFromList
- //---------------------------------------------------------------------------------------
-
- FW_MScriptable* FW_CSemanticInterface::CreateCollectionFromList(Environment* ev,
- FW_CPart* part,
- const FW_CDesc& objectList,
- ODDescType whichProperty) const
- {
- FW_ASSERT(objectList.IsList());
-
- // FW_DebugIdentifyPart(ev, fPart->GetLastActiveFrame(ev), FW_kRGBPurple);
-
- FW_CScriptableCollection* collection = FW_NEW(FW_CScriptableCollection, ());
-
- FW_CDesc currentODToken;
- FW_CDesc currentToken;
- long itemsInList = objectList.GetItemCount();
-
- for (long index = 1; index <= itemsInList; index++)
- {
- currentODToken.Clear();
- currentToken.Clear();
-
- objectList.GetDescFromList(index, currentODToken);
- currentToken = GetDescFromToken(ev, currentODToken);
-
- FW_MScriptable* semObj = ::FW_ExtractScriptableFromDesc(currentToken);
-
- if (whichProperty != keyNoKey)
- {
- FW_CPropertyDesignator* propDesignator;
-
- propDesignator = FW_NEW(FW_CPropertyDesignator, (part, semObj, whichProperty));
- collection->Add(propDesignator);
- }
- else
- collection->Add(semObj);
- }
- return collection;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::GetDescFromToken
- //---------------------------------------------------------------------------------------
-
- ODDesc* FW_CSemanticInterface::GetDescFromToken(Environment* ev,
- ODOSLToken* token) const
- {
- ODNameResolver* nameResolver = FW_CSession::GetNameResolver(ev);
- return (nameResolver->IsODToken(ev, token) ? nameResolver->GetUserToken(ev, token) : token);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::ParseStandardPartToken
- //---------------------------------------------------------------------------------------
-
- void FW_CSemanticInterface::ParseStandardPartToken(Environment* ev,
- const FW_CDesc& token,
- ODPart** odPart,
- ODFrame** odFrame) const
- {
- FW_UNUSED(ev);
- struct FW_SPrivStandardPartToken
- {
- ODFrame* fFrame;
- ODPart* fPart;
- };
-
- const FW_CDesc* partToken = &token;
- FW_CDesc coercedToken;
-
- if (token.DescriptorType() != kODStandardPartTokenType)
- {
- token.Coerce(kODStandardPartTokenType, coercedToken);
- partToken = &coercedToken;
- }
-
- FW_ASSERT(token.DescriptorType() == kODStandardPartTokenType);
- FW_ASSERT(token.PlatformDataHandle() != NULL);
-
- FW_SPrivStandardPartToken standardToken;
-
- partToken->GetDataByPtr(typeWildCard, &standardToken, NULL, sizeof(FW_SPrivStandardPartToken));
-
- if (odPart)
- *odPart = standardToken.fPart;
-
- if (odFrame)
- *odFrame = standardToken.fFrame;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::IsStandardPartToken
- //---------------------------------------------------------------------------------------
-
- FW_Boolean FW_CSemanticInterface::IsStandardPartToken(const FW_CDesc& token) const
- {
- FW_Boolean result = (token.DescriptorType() == kODStandardPartTokenType);
-
- if (!result)
- {
- FW_CDesc coercedDesc;
-
- FW_TRY
- {
- token.Coerce(kODStandardPartTokenType, coercedDesc);
- if (coercedDesc.DescriptorType() == kODStandardPartTokenType)
- result = true;
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING()
- {
- // don't propogate exceptions
- }
- FW_CATCH_END
- }
-
- return result;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::AcquireTargetObject
- //---------------------------------------------------------------------------------------
-
- FW_MScriptable* FW_CSemanticInterface::AcquireTargetObject(Environment* ev,
- FW_CAppleEvent& event)
- {
- ODNameResolver* nameResolver = FW_CSession::GetNameResolver(ev);
- FW_MScriptable* result = NULL;
-
- if (event.HasDataKey(keyDirectObject))
- {
- FW_CDesc directObjectToken;
-
- event.GetDataByDesc(directObjectToken, keyDirectObject);
-
- // the direct object is not always an object specifier (e.g "beep 1")
- if (nameResolver->IsODToken(ev, directObjectToken))
- result = AcquireScriptableFromToken(ev, directObjectToken);
- }
-
- if (result == NULL && event.HasAttribute(keySubjectAttr))
- {
- FW_CDesc subjectDesc;
- FW_CDesc resolvedSubjectAttribute;
-
- event.GetSubject(subjectDesc);
-
- // With OpenDoc 1.1 and earlier, the subject attribute is an unresolved
- // object specifier. With OpenDoc 1.2 and later, the subject attribute
- // should be a user token representing a resolved object specifier. This
- // code handles either case.
- if (subjectDesc.DescriptorType() == typeObjectSpecifier)
- {
- Resolve(ev, subjectDesc, resolvedSubjectAttribute);
- subjectDesc = resolvedSubjectAttribute;
- }
-
- FW_TRY
- {
- result = AcquireScriptableFromToken(ev, subjectDesc);
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING()
- {
- nameResolver->DisposeToken(ev, resolvedSubjectAttribute);
- FW_THROW_SAME();
- }
- FW_CATCH_END
-
- nameResolver->DisposeToken(ev, resolvedSubjectAttribute);
- }
-
- if (result == NULL)
- FW_Failure(errAEEventNotHandled);
-
- return result;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::Resolve
- //---------------------------------------------------------------------------------------
-
- void FW_CSemanticInterface::Resolve(Environment* ev,
- const FW_CDesc& objectSpec,
- FW_CDesc& odfToken,
- ODPart* contextPart) const
- {
- if (objectSpec.IsNullDescriptor())
- {
- odfToken.Clear();
- }
- else
- {
- ODNameResolver* nameResolver = FW_CSession::GetNameResolver(ev);
-
- nameResolver->Resolve(ev, objectSpec, odfToken, contextPart);
- odfToken.SetOwnsODData(FALSE);
- }
- }
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::AcquireScriptableFromToken
- //---------------------------------------------------------------------------------------
-
- FW_MScriptable* FW_CSemanticInterface::AcquireScriptableFromToken(Environment* ev,
- const FW_CDesc& odToken) const
- {
- FW_MScriptable* scriptable = NULL;
- FW_CDesc ourToken = GetDescFromToken(ev, odToken);
- ODDescType ourTokenType = ourToken.DescriptorType();
- FW_Boolean ourTokenIsStandardPartToken = IsStandardPartToken(ourToken);
- ODFrame* tokenFrame;
- ODPart* tokenPartWrapper = NULL;
- ODPart* realTokenPart = NULL;
- ODPart* myPartWrapper = NULL;
- ODPart* myRealPart = NULL;
-
- // An event that has no direct object, or whose direct object is not an object specifier,
- // has a standard part token inside of the odToken that describes the part at which the
- // event is targeted. Bugs in OpenDoc cause the event to sometimes get dispatched to the
- // wrong part first. We attempt to identify this case here, and throw an exception when
- // we receive an event not targeted at us. This causes OpenDoc to ultimately dispatch the
- // event to the correct target.
-
- // If the token contains standard part token, we parse it ourselves to extract the target
- // part. The OpenDoc team has agreed that the structure of standard part tokens must
- // be exposed to correctly implement this recipe. The structure of standard part
- // tokens will not change in future versions of OpenDoc.
- // If the token does not contain a standard part token, we ask the name resolver for
- // the context of the token.
-
- // if the odToken is the null descriptor, there was no direct object and no subject
- // attribute. If this is the case, the event _must_ be targeted at the root part,
- // and we _must_ be the root part, since events are never mistakenly dispatched to
- // parts embedded in the real target.
- if (!odToken.IsNullDescriptor())
- {
- if (ourTokenIsStandardPartToken)
- ParseStandardPartToken(ev, ourToken, &tokenPartWrapper, NULL);
- else
- FW_CSession::GetNameResolver(ev)->GetContextFromToken(ev, odToken, &tokenPartWrapper, &tokenFrame);
-
- if (tokenPartWrapper != NULL)
- {
- realTokenPart = tokenPartWrapper->GetRealPart(ev);
- if (realTokenPart) // don't release it if we didn't acquire it
- tokenPartWrapper->ReleaseRealPart(ev);
- }
- else
- realTokenPart = NULL;
-
- FW_ASSERT(realTokenPart != NULL);
-
- myPartWrapper = GetPart()->GetODPart(ev);
- myRealPart = myPartWrapper->GetRealPart(ev);
- if (myRealPart) // don't release it if we didn't acquire it
- myPartWrapper->ReleaseRealPart(ev);
-
- FW_ASSERT(myRealPart != NULL);
-
- // If the part we got from parsing the token or calling GetContextFromToken is not
- // our part, then the event was mistakenly dispatched to us.
-
- if (realTokenPart == NULL || myRealPart == NULL || realTokenPart != myRealPart)
- FW_Failure(errAEEventNotHandled);
- }
-
- if (ourToken.IsNullDescriptor() || ourTokenIsStandardPartToken)
- {
- scriptable = GetDefaultContainer();
- scriptable->AcquireScriptable();
- }
- else if (ourTokenType == FW_kSemanticObjectTokenType)
- {
- scriptable = ::FW_ExtractScriptableFromDesc(ourToken);
- scriptable->AcquireScriptable();
- }
- else if (ourToken.IsList())
- {
- scriptable = CreateCollectionFromList(ev, fPart, ourToken);
- }
- else
- FW_Failure(errAEEventNotHandled);
-
- return scriptable;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_DebugIdentifyPart:
- // This utility method is for debugging semantic event handling in nested parts.
- // A circle of the specified color will be briefly displayed in the top left
- // corner of the first facet of the specified frame. This method does not attempt
- // to redraw or invalidate the content area obscured by the circle.
- //
- // Note: This method may not be a permanent part of the ODF API.
- //---------------------------------------------------------------------------------------
-
- void FW_DebugIdentifyPart(Environment* ev, FW_CFrame* frame, const FW_CColor& color)
- {
- if (frame)
- {
- FW_CFrameFacetIterator iter(ev, frame);
- FW_CViewContext vc(ev, frame, iter.First(ev), NULL);
- FW_CRect rect(FW_kFixed0, FW_kFixed0, FW_IntToFixed(10), FW_IntToFixed(10));
-
- FW_CInk ink;
- ink.SetForeColor(color);
- ink.SetTransferMode(FW_kCopy);
- FW_COvalShape::RenderOval(vc, rect, FW_kFill, ink);
- FW_WaitFor(20);
- ink.SetTransferMode(FW_kErase);
- FW_COvalShape::RenderOval(vc, rect, FW_kFill, ink);
- }
- }
-
- //========================================================================================
- // End Callbacks
- //========================================================================================
-
- //---------------------------------------------------------------------------------------
- // FW_CSemanticInterface::PrivCreate
- //---------------------------------------------------------------------------------------
-
- ODExtension* FW_CSemanticInterface::PrivCreate(Environment* ev, FW_CPart* part, const char* name, void* refCon)
- {
- return (part->GetSemanticInterface(ev)->CreateSOMInterface(ev, part, name, refCon));
- }
-